package com.dcjt.firehotcarpad.fragment

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.aries.library.fast.basis.BasisFragment
import com.aries.library.fast.manager.TabLayoutManager
import com.aries.ui.widget.progress.UIProgressView
import com.dcjt.firehotcarpad.R
import com.dcjt.firehotcarpad.entity.DisasterInfoEntity
import com.flyco.tablayout.SlidingTabLayout

import java.util.*


class SystemOperationFragment : BasisFragment() {
    private var disasterInfoFragment: DisasterInfoFragment? = null
    private var aroundWaterFragment: AroundWaterFragment? = null
    private var freeDocumentFragment: FreeDocumentFragment? = null

    companion object {
        fun newInstance(): SystemOperationFragment {
            val fragment = SystemOperationFragment()
            return fragment
        }
    }

    override fun getContentLayout(): Int = R.layout.fragment_system_operation
    override fun initView(savedInstanceState: Bundle?) {
        val lisFragment: MutableList<Fragment> =
            ArrayList()
        disasterInfoFragment = DisasterInfoFragment.newInstance()
        aroundWaterFragment = AroundWaterFragment.newInstance("周边水源")
        freeDocumentFragment = FreeDocumentFragment()
        lisFragment.add(disasterInfoFragment!!)
        lisFragment.add(aroundWaterFragment!!)
        lisFragment.add(freeDocumentFragment!!)
//        lisFragment.add(P2PMessageFragment.newInstance("聊天","聊天","聊天",SessionTypeEnum.ChatRoom))

        var tabLayoutSliding =  findViewById<SlidingTabLayout>(R.id.tabLayout_sliding)
        var vpContent =  findViewById<ViewPager>(R.id.vp_contentFastLib)

        TabLayoutManager.getInstance().setSlidingTabData(
            this, tabLayoutSliding, vpContent,
            getTabTitles(), lisFragment
        )
    }
    public fun setDisasterInfo(disasterEntity : DisasterInfoEntity) {
//        disasterInfoFragment?.setDisasterInfo(disasterEntity)
        aroundWaterFragment?.setDisasterInfo(disasterEntity)
//        freeDocumentFragment?.setDisasterInfo(disasterEntity.id)
    }

    @SuppressLint("UseRequireInsteadOfGet")
    override fun beforeInitView() {
//        type = arguments!!.getInt("type")
        super.beforeInitView()
    }

    private fun getTabTitles(): List<String> {
        return mContext.getResources().getStringArray(R.array.arrays_title).toList()
    }



}
